package cn.com.idmy.auth.rbac;


import org.jetbrains.annotations.NotNull;

import java.util.Collection;

public interface RbacDao<ID> {
    default void init() {
    }

    default void destroy() {
    }

    @NotNull Collection<String> listPermissions(@NotNull ID id, long accountType);

    @NotNull Collection<String> listRoles(@NotNull ID id, long accountType);

    boolean hasAllRoles(@NotNull ID id, long accountType, @NotNull Collection<String> roles);

    boolean hasAnyRoles(@NotNull ID id, long accountType, @NotNull Collection<String> roles);

    boolean hasAllPermissions(@NotNull ID id, long accountType, @NotNull Collection<String> permissions);

    boolean hasAnyPermissions(@NotNull ID id, long accountType, @NotNull Collection<String> permissions);

    default void clear(@NotNull ID id, long accountType) {
        clearRoles(id, accountType);
        clearPermissions(id, accountType);
    }

    void clearRoles(@NotNull ID id, long accountType);

    void clearPermissions(@NotNull ID id, long accountType);
}
